﻿using System;

namespace CS.Caching
{
    /// <summary>
    ///缓存接口
    /// </summary>
    public interface ICache
    {
        /// <summary>
        /// 根据键索引返回缓存值
        /// </summary>
        /// <modelExp name="key"></modelExp>
        /// <returns></returns>
        object this[object key]
        {
            get;
            set;
        }

        /// <summary>
        /// 缓存数量
        /// </summary>
        int Count
        {
            get;
        }

        /// <summary>
        ///是否包含缓存项
        /// </summary>
        /// <modelExp name="key"></modelExp>
        /// <returns></returns>
        bool ContainsKey(object key);

        /// <summary>
        ///移除缓存
        /// </summary>
        /// <modelExp name="key"></modelExp>
        void Remove(object key);

        /// <summary>
        /// 清除所有缓存
        /// </summary>
        void Clear();

        /// <summary>
        /// 加入缓存项
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="cacheDependency"></param>
        void Insert(string key, object value, object cacheDependency);

        /// <summary>
        /// 加入缓存项
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="cacheDependency"></param>
        /// <param name="absoluteExpiration"></param>
        /// <param name="slidingExpiration"></param>
        void Insert(string key, object value, object cacheDependency, DateTime absoluteExpiration, TimeSpan slidingExpiration);

        /// <summary>
        /// 加入缓存项
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="absoluteExpiration"></param>
        /// <param name="slidingExpiration"></param>
        void Insert(string key, object value, DateTime absoluteExpiration, TimeSpan slidingExpiration);
    }
}